//
//  SeeAskUserImgTableViewCell.m
//  PropertyManager
//
//  Created by TNG on 2018/7/30.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "SeeAskUserImgTableViewCell.h"

@implementation SeeAskUserImgTableViewCell

static NSString * SeeAskUserImgCollectionViewCellID = @"SeeAskUserImgCollectionViewCell";

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatUI];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

-(void)creatUI{
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.collectionView];
}

-(void)send
{
    self.bgView.frame = CGRectMake(20, 0, WIDTH - 40, (WIDTH - 94)/4 * 2 + 10 * 1 + 50);
}

-(UIView *)bgView
{
    if (_bgView == nil) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = SFM242;
    }
    return _bgView;
}

-(UICollectionView *)collectionView
{
    if (_collectionView == nil)
    {
        UICollectionViewFlowLayout * floweLayout =[[UICollectionViewFlowLayout alloc]init];
        floweLayout.itemSize=CGSizeMake((WIDTH - 94)/4, (WIDTH - 94)/4);
        floweLayout.minimumLineSpacing= 10;
        floweLayout.minimumInteritemSpacing = 0;
        floweLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(12, 14, WIDTH - 64, (WIDTH - 94)/4 * 2 + 10 * 1) collectionViewLayout:floweLayout];
        _collectionView.dataSource =self;
        _collectionView.delegate = self;
        _collectionView.bounces = NO;
        _collectionView.backgroundColor=[UIColor whiteColor];
        _collectionView.pagingEnabled = YES;
        _collectionView.showsVerticalScrollIndicator = NO;
        [_collectionView registerClass:[SeeAskUserImgCollectionViewCell class] forCellWithReuseIdentifier:SeeAskUserImgCollectionViewCellID];
    }
    return _collectionView;
}

#pragma mark <UICollectionViewDataSource>

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 8;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    SeeAskUserImgCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:SeeAskUserImgCollectionViewCellID forIndexPath:indexPath];
    cell.img.backgroundColor = SFMRandColor;
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    [collectionView deselectItemAtIndexPath:indexPath animated:YES];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
